package com.qian.apiserver.service;

import com.qian.apiserver.entity.GmCount;
import java.math.BigDecimal;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import com.qian.apiserver.model.Count;
import com.yaowk.service.common.BaseRepository;
import java.lang.Byte;
import com.yaowk.service.common.BaseServiceImpl;
import java.lang.Integer;
import com.qian.apiserver.service.ICountService;
import com.qian.apiserver.dao.CountDao;

public abstract class CountServiceBase extends BaseServiceImpl<Count, GmCount, Integer> implements ICountService {

	@Autowired
	private CountDao dao;

	@Override protected CountDao getDao() {
	return dao;
	}

	@Override
	protected Count entity2model(GmCount entity) {
		Count model = null;
		if(isNotEmpty(entity)){
			model = new Count();
			model.setId(entity.getId());
			model.setTime(entity.getTime());
			model.setBetting(entity.getBetting());
			model.setWinChip(entity.getWinChip());
			model.setCode(entity.getCode());
		}
		return model;
	}

	@Override
	protected GmCount model2Entity(Count model) {
		GmCount entity = null;
		if(isNotEmpty(model)){
			entity = new GmCount();
			entity.setId(model.getId());
			entity.setTime(model.getTime());
			entity.setBetting(model.getBetting());
			entity.setWinChip(model.getWinChip());
			entity.setCode(model.getCode());
		}
		return entity;
	}

	@Override
	protected GmCount updateParams(Count model) {
		GmCount entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getTime()))
			entity.setTime(model.getTime());
		if(isNotEmpty(model.getBetting()))
			entity.setBetting(model.getBetting());
		if(isNotEmpty(model.getWinChip()))
			entity.setWinChip(model.getWinChip());
		if(isNotEmpty(model.getCode()))
			entity.setCode(model.getCode());
		return entity;
	}


}